package com.lbn.monitor.widget;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.TextView;

import com.lbn.monitor.util.String2Num;

/**
 * @author 李炳南
 * @date 2017/3/16
 */
public class NumCTextView extends TextView{

    public NumCTextView(Context context) {
        this(context,null);
    }

    public NumCTextView(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public NumCTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    public void setText(String value,double standard){
        setText(String2Num.str2Double(value),standard);
    }

    public void setText(double value,double standard) {
        if(value>standard){
            setTextColor(Color.parseColor("#ff0000"));
        }else{
            setTextColor(Color.parseColor("#7FFF00"));
        }
        setText(String.valueOf(value));
    }

}
